package server

import (
	"github.com/jiushengTech/common/transport/socket"
	"transfer-service/internal/biz"
	"transfer-service/internal/conf"
	"transfer-service/internal/global"
)

func NewAntiCarTcpServer(conf *conf.Bootstrap) *biz.AntiCarTcpServer {
	c := conf.GetServer().GetSocket().GetAntiCar()
	res := socket.NewTCPServer(
		socket.WithNetwork(c.GetNetwork()),
		socket.WithAddress(c.GetAddr()),
		socket.WithTargetAddr(c.GetTargetAddr()),
		socket.WithTimeout(c.GetTimeout().AsDuration()),
	)
	global.LOG.Infof("反制车 "+c.GetNetwork()+" server listening on: %s", c.GetAddr())
	return &biz.AntiCarTcpServer{
		TCPServer: res,
	}
}

func NewAntiGunTcpServer(conf *conf.Bootstrap) *biz.AntiGunTcpServer {
	c := conf.GetServer().GetSocket().GetAntiGun()
	res := socket.NewTCPServer(
		socket.WithNetwork(c.GetNetwork()),
		socket.WithAddress(c.GetAddr()),
		socket.WithTargetAddr(c.GetTargetAddr()),
		socket.WithTimeout(c.GetTimeout().AsDuration()),
	)
	global.LOG.Infof("反制枪 "+c.GetNetwork()+" server listening on: %s", c.GetAddr())
	return &biz.AntiGunTcpServer{TCPServer: res}
}
